﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace StoreManagement_Application
{
    public partial class AddProduct : Form
    {

        #region product details
        SaveProduct prdtls = new SaveProduct();
        #endregion


        public AddProduct()
        {
            InitializeComponent();


        }

        #region Clearing the Fields

        public void ClearFields()
        {
         
       foreach(Control controls in groupBox1.Controls)
            {

                if (controls is TextBox)
                {
                    ((TextBox)controls).Text = string.Empty;

                }
            }
        }
        #endregion

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }


        //Saving Product Details
        private void btnsave_Click(object sender, EventArgs e)
        {


            #region saving the products

            Guid ProductiD = System.Guid.NewGuid();

            prdtls.ProductID = ProductiD.ToString();

            prdtls.ReceivedDate = receiveddate.Value;
            prdtls.ExpiryDate = expirydate.Value;
            prdtls.Type = txttype.Text;
            prdtls.Company = txtcompany.Text;
            prdtls.ProductName = txtproduct.Text;
            prdtls.PurchasedRate = Convert.ToString(numrate.Value);


            prdtls.Quantity = Convert.ToString(numquantity.Value);
            prdtls.CreditorsName = txtcreditorsname.Text;
            prdtls.Description = txtDescription.Text;


            string asd = DataAccessLayer.Saveproductdetial(prdtls);
            MessageBox.Show("Product "+asd);

            #endregion
        }

        private void button2_Click(object sender, EventArgs e)
        {
            ClearFields();


            // my name  is rahul
        }


    }
}


